<?
	//write a check if player has an unknown race, class, title value
	//Check out DB, if GUID in there, go on
	//Build for Openbasic
	
	include 'config/config.php';
	include 'describtion/desc.php';

	include 'template/head.html';
	
	$connectDB = @mysql_connect($adresse, $dbuser, $dbpass);
	if(!isset($connectDB))
	{
		echo $connectDB['fail'];
		exit;
	}
	$selcetDB = mysql_select_db($dbname);
	if(!isset($selectDB))
	{
		echo $selectDB['fail'];
		exit;
	}
	$searchChar = mysql_query("SELECT * FROM characters WHERE name = '".$_POST['name']."';");
	//Check if playerchar exist in DB
	if($searchChar == false)
	{
		echo $fail['char'];
		exit;
	}
	//check if player has an unknown race, class, title value
	if($result['race'] >= 12)
	{
		echo $fail['race'];
		exit;
	}
	if($result['class'] >= 12)
	{
		echo $fail['class'];
		exit;
	}
	if($result['selected_pvp_title'] >= 178) //es gibt eigentlich nur 177, dank buddi sinds 178 XD
	{
		echo $fail['title'];
		exit;
	}
	$result = mysql_fetch_assoc($searchChar);
	$searchGuildID = mysql_query("SELCET * FROM guild_data WHERE playerid = '".$result['guid']."';");
	//if no guildname of the selected char, give him this value else grab the guildname
	if($searchGuildID == false)
	{
		$result2['guildname'] = "- - -";
	}
	else
	{
		$result1 = mysql_fetch_assoc($searchGuildID);
		$searchGuild = mysql_query("SELCET * FROM guilds WHERE guildId = '".$result1['guildid']."';");
		$result2 = mysql_fetch_assoc($searchGuild);
	}
	//faction check 0 = horde, 1 = ally
	$faction = 0;
	if($result['race'] = 01 || $result['race'] = 03 || $result['race'] = 04 || $result['race'] = 07 || $result['race'] = 11)
	{
		$faction = 1;
	}
	//check if guid already insert or not
	$checkName = mysql_query("SELECT * FROM signatur WHERE GUID = '".$result['guid']."';");
	if($checkName == false)
	{
		$com = mysql_query("INSERT INTO signatur (`guid`, `background`, `color`, `choose`, `choose1`, `choose2`) VALUES
							 ('".$result['guid']."', '".$bg."', '".$color."', '".$choose."', '".$choose1."', '".$choose2."');");
	}
	else
	{
		$com = mysql_query("UPDATE signatur SET background = '".$bg."',
												color 	   = '".$color."',
												choose	   = '".$choose."',
												choose1	   = '".$choose1."',
												choose2	   = '".$choose2."',
							WHERE guid = '".$result['guid']."';");
	}
?>
<br>
<center>
	<div class="beitrag">
		<center>
			<br>
			So sieht deine Signatur aus.
			<br>
			<br>
			<?
				//if only 1 of these 2 query's sends true create signatur
				if($insert == true xor $update == true)
				{
					echo '<img src="';
					echo 'sig.php?GUID='.$result['guid'];
					echo '">';
				}
			?>
			<br>
			<br>
			Fuer Foren kannst du das benutzen:
			<br>
			<div class="entrieB">
				<input type="text" value="<? echo '[url='; echo $serveradress; echo$folder; echo ']'; echo '[img]'; echo $serveradress; echo $folder; echo 'sig.php?GUID='.$result['guid']; echo '[/img][/url]'; ?>" size="44">
			</div>
			<br>
			<br>
		</center>
		<form action="<? echo $serveradress.$folder; ?>">
			<input type="submit" value="Go Back">
		</form>
	</div>
</center>
<br>
<?
	include 'template/foot.html';
?>